class Solution {
public:
    int findWinningPlayer(vector<int>& skills, int k)
    {
        int ans = 0;
        queue<int> q;
        for (auto& a : skills) q.push(a);
        int start = q.front();
        q.pop();
        int cnt = 0;
        while (cnt < k && cnt < skills.size() + 10)
        {
            if (start > q.front())
            {
                cnt++;
                q.push(q.front());
                q.pop();
            }
            else
            {
                cnt = 1;
                q.push(start);
                start = q.front();
                q.pop();
            }
        }
        for (int i = 0; i < skills.size(); i++) if (start == skills[i]) return i;

        return -1;
    }
};